import request from '@/utils/request';
/**
 * 站点列表增加
 * @param params 查询条件
 */

export async function siteNoticeInsert(data) {
  const res = await request.post('/massage/siteAnnouncementConfig', data);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 轮播图列表查询
 * @param params 查询条件
 */

export async function siteNoticeList(params) {
  const res = await request.get('/massage/siteAnnouncementConfig', {
    params
  });

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 站点列表修改
 * @param params 查询条件
 */

export async function siteNoticeModify(data) {
  const res = await request.put('/massage/siteAnnouncementConfig', data);
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 站点列表查询
 * @param params 查询条件
 */

export async function siteNoticeDetail(params) {
  const res = await request.get('/massage/siteAnnouncementConfig/get', {
    params
  });

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 站点列表删除
 * @param params 查询条件
 */

export async function siteNoticeDelete(id) {
  const res = await request.delete('/massage/siteAnnouncementConfig/' + id);
  console.log(res);
  if (res.data.code === 200) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
